<template>
	<view class="content">
		<view v-for="(item,index) in newsArray" :key='index'>
			<view class="news-time">{{item.create_time_text}}</view>
			<view class="news-content">
				<view class="news-content-title">
					<image class="news-content-title-icon" :src="newsIcon" mode=""></image>
					<text>{{item.type_text}}</text>
				</view>
				<view class="news-content-text">
					<rich-text :nodes="item.content"></rich-text>
				</view>
			</view>
		</view>
		<view v-if='newsArray.length == 0'>~暂无消息~</view>
	</view>
</template>

<script>
	import http from '../../api/api-index.js'
	import baseUrl from '../../utils/config.js'
	
	export default{
		data(){
			return{
				newsIcon:baseUrl+'/uploads/static/image/recovery_message_icon@2x.png',
				newsArray:[],
				page:1
			}
		},
		onLoad() {
			this.getNewsFun()
		},
		onReachBottom(){
			this.page = this.page++
			this.getNewsFun()
		},
		methods:{
			getNewsFun(){
				http.getNewsList({
					page:this.page
				}).then((res)=>{
					console.log(res)
					this.newsArray = res.data.data
				})
			}
		}
	}
</script>

<style>
	.content{
		width: 100%;
		min-height: 100vh;
		overflow: hidden;
		background: #F8F9FD;
		font-family: 'PingFang Bold';
	}
	.news-time{
		width: 140px;
		height: 26px;
		font-size: 12px;
		color: #fff;
		background: #D8D9E2;
		border-radius: 5px;
		text-align: center;line-height: 26px;
		margin: 0 auto;
		margin-top: 30px;
	}
	.news-content{
		width: calc(100% - 24px);
		margin: 0 auto;
		margin-top: 15px;
		border-radius: 10px;
		background: #fff;
		box-sizing: border-box;
		padding:20px;
	}
	.news-content-title{
		width: 100%;
		display: flex;flex-direction: row;align-items: center;
		box-sizing: border-box;
		padding-bottom: 15px;
		border-bottom: 1px solid #f6f6f6;
	}
	.news-content-title-icon{width: 24px;height: 24px;margin-right: 8px;}
	.news-content-title text{font-size: 16px;color: #333;}
	.news-content-text{width: 100%;margin-top: 20px;font-size: 14px;color: #666;}
</style>